if exists (select * from dbo.sysobjects where id = object_id(N'[dbo].[GetLastFeedRunDates]') and OBJECTPROPERTY(id, N'IsProcedure') = 1)
drop procedure [dbo].[GetLastFeedRunDates]
GO
SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO     
/************************************************************************************************                      
* Name  : GetLastFeedRunDates                                                                                
* Purpose: This stored procedure retrieves the Lastfeed run date for the all the modules                 
*     
*                        
* PARAMETERS                        
* Name   Description                      
* ------------------------- -----------------------------                      
* None      
*                      
************************************************************************************************                      
*Call: [GetLastFeedRunDates]                       
************************************************************************************************/                         
CREATE procedure dbo.GetLastFeedRunDates                      

as                        
begin                        
 set nocount on                 
 Select 
		max(endDate)as 'LastFeedRunDate' 
		, svcType.Name as 'FeedRunType'
	from SvcFeedRun 
	inner join SvcFeedType svcType 
		on svcType.Id = SvcfeedTypeId 
	Where svcfeedstatustypeid = (select id from SvcFeedStatusType where [Name] = 'Completed')
	group by 
			 svcFeedtypeId
			,svcType.name 
	order by SvcFeedTypeId
end                        
                
              
 